package k1_exercise;

import java.util.Arrays;

public class Array_headTailItemSwapByNewArray {

    /**
     * 首尾交换 {1,2,5,6,7,9}  ->  {9,7,6,5,2,1}
     */
    public static void main(String[] args) {

        //初始化原数组
        int[] nums = {1,2,5,6,7,9,3};
        //根据原数组的长度创建一个新数组
        int[] numsNew = new int[nums.length];

        for (int i = 0; i < numsNew.length; i++) {
            numsNew[i] = nums[nums.length-1-i];
        }
        System.out.println(Arrays.toString(numsNew));
    }
}